----------------------------------Spell Variables--------------------------------------
SPELL.m_iSpellID = 21312 -- Whatever value you want as long as it doesn't override any other spells' IDs.
SPELL.m_iRange = 240
SPELL.m_sName = "Weapon Switch"
SPELL.m_sToolTip =	[[You switch between your
					twohander and sword/shield, 
					trading defense for damage 
					and vice-versa.]]	
SPELL.m_sIcon = "devin/blackbetty/spells/warrior/shield_slam.png"
SPELL.m_sReplaceIcon = "devin/blackbetty/spells/warrior/shadowblade.png"
SPELL.m_iCoolDown = 0
SPELL.m_iManaCost = 0
SPELL.m_bRequiresTarget = false
SPELL.m_bRecastWhileCasting = true
SPELL.m_iSpellType = SPELLTYPE_MELEEDAMAGE

---------------------------------------------------------------------------------------

local range = 100
local weapondamage = 10

function SPELL:Cast( pl, target )

	if(pl.MainHand != nil and pl.MainHand:IsValid())then
		pl.MainHand:Remove()
		pl.MainHand = nil
	end
	
	net.Start("IncurGCD")
	net.WriteFloat(5)
	net.Send(pl)
	
	pl.MainHand = ents.Create("prop_dynamic")
	pl.MainHand:SetModel("models/devin/rpgdm_weapons/basic/broadsword.mdl")
	pl.MainHand:PhysicsInit(SOLID_VPHYSICS)
	pl.MainHand:SetMoveType(MOVETYPE_NONE)
	pl.MainHand:SetSolid( SOLID_VPHYSICS )
	pl.MainHand:SetParent(pl)
	pl.MainHand:AddEffects( EF_BONEMERGE )
	pl.MainHand:SetCollisionGroup( COLLISION_GROUP_NONE )
	
	if(pl.OffHand != nil and pl.OffHand:IsValid())then
		pl.OffHand:Remove()
		pl.OffHand = nil
	end
	
	pl.OffHand = ents.Create("prop_dynamic")
	pl.OffHand:SetModel("models/devin/rpgdm_weapons/basic/blueshield.mdl")
	pl.OffHand:PhysicsInit(SOLID_VPHYSICS)
	pl.OffHand:SetMoveType(MOVETYPE_NONE)
	pl.OffHand:SetSolid( SOLID_VPHYSICS )
	pl.OffHand:SetParent(pl)
	pl.OffHand:AddEffects( EF_BONEMERGE )
	pl.OffHand:SetCollisionGroup( COLLISION_GROUP_NONE )
	pl:SetNWString("HoldType", "knife") 
	local weapon = pl:GetWeapon("weapon_all")
	print("Casted "..self.m_sName.."!")
	pl:EmitSound("devin/blackbetty/weapons/ShieldWall.wav", 150, 100 + math.random(-10, 10))
	pl.Block = 0.5
	pl.ArmorStat = 4
	pl.Shield = true
	weapon.MinWeaponDamage = 3
	weapon.MaxWeaponDamage = 5
end

function SPELL:Recast( pl, target )
	
	if(pl.MainHand != nil and pl.MainHand:IsValid())then
		pl.MainHand:Remove()
		pl.MainHand = nil
	end
	
	pl.MainHand = ents.Create("prop_dynamic")
	pl.MainHand:SetModel("models/devin/rpgdm_weapons/basic/bm_sword1.mdl")
	pl.MainHand:PhysicsInit(SOLID_VPHYSICS)
	pl.MainHand:SetMoveType(MOVETYPE_NONE)
	pl.MainHand:SetSolid( SOLID_VPHYSICS )
	pl.MainHand:SetParent(pl)
	pl.MainHand:AddEffects( EF_BONEMERGE )
	pl.MainHand:SetCollisionGroup( COLLISION_GROUP_NONE )
	
	if(pl.OffHand != nil and pl.OffHand:IsValid())then
		pl.OffHand:Remove()
		pl.OffHand = nil
	end
	
	pl.OffHand = ents.Create("prop_dynamic")
	pl.OffHand:SetModel("")
	pl.OffHand:PhysicsInit(SOLID_VPHYSICS)
	pl.OffHand:SetMoveType(MOVETYPE_NONE)
	pl.OffHand:SetSolid( SOLID_VPHYSICS )
	pl.OffHand:SetParent(pl)
	pl.OffHand:AddEffects( EF_BONEMERGE )
	pl.OffHand:SetCollisionGroup( COLLISION_GROUP_NONE )
	
	pl:EmitSound("devin/blackbetty/weapons/Disarm.wav", 150, 100 + math.random(-10, 10))
	pl.Block = 0
	pl.ArmorStat = 0
	pl.Shield = false
	pl:SetNWString("HoldType", "melee2") 
	local weapon = pl:GetWeapon("weapon_all")
	weapon.MinWeaponDamage = 7
	weapon.MaxWeaponDamage = 10
end






